import React, {Component} from 'react'
import {View, Text, Platform, StyleSheet} from 'react-native'
import {StackNavigator, TabNavigator} from 'react-navigation'
import CardStackStyleInterpolator from 'react-navigation/src/views/CardStack/CardStackStyleInterpolator'
import Icon from 'react-native-vector-icons/Ionicons'
import HomeworkIndex from '../components/homeworks/index'
import NewHomework from '../components/homeworks/new'
import AddTextBook from '../components/homeworks/add_text_book'
import BookSelector from '../components/common/book_selector'
import UnitSelector from '../components/common/unit_selector'
import SectionSelector from '../components/common/section_selector'
import AddHomeworkDescribe from '../components/homeworks/add_homework_describe'
import NewHomeworkStage2 from '../components/homeworks/new_stage2'
import NotificationIndex from '../components/notification/index'
import SelfLearningIndex from '../components/self_learning/index'
import PersonalIndex from '../components/personal/index'
import HomeworkShow from '../components/homeworks/show'
import HomeworkCorrecting from '../components/homeworks/correcting'
import HomeworkTaskList from '../components/homeworks/homework_task_list'
import CorrectingWithTask from '../components/homeworks/correcting_with_task'
import StudentHomeworkShow from '../components/homeworks/student_homework_show'
import StudentDoHomework from '../components/homeworks/student_do_homework'
import CorrectingWithBatch from '../components/homeworks/correcting_with_batch'
import newHomeworkWithoutText from '../components/homeworks/new_without_text'
import NotificationShow from '../components/notification/show'
import NotificationCorrecting from '../components/notification/correcting'
import NewNotification from '../components/notification/new'
import NewNotificationStage2 from '../components/notification/new_stage2'
import newHomeworkWithText from '../components/homeworks/new_with_text'
import Ranking from '../components/self_learning/ranking'
import PhotoBrowserScene from '../components/common/photo'
import VideoBrowserScene from '../components/common/video'
import TeacherCorrect from '../components/homeworks/teacher_correct'
import SelfLearningShow from '../components/self_learning/show'
import ChaptersList from '../components/self_learning/chapters2'
import Challenge from '../components/self_learning/challenge'
import ChallengerReport from '../components/self_learning/challenger_report'
import Feedback from '../components/personal/feedback'
import CircleSliderAudio from '../components/common/circle_slider_audio'
import GradeSelector from '../components/common/grade_selector'
import Symbol from '../components/statics/symbol'
import StudentSymbol from '../components/statics/student_symbol'
import SymbolDetail from '../components/statics/symbol_detail'
import SwichRole from '../components/personal/swichRole'
import StudentStaticIndex from '../components/statics/student_static_index'
import ClassStaticsIndex from '../components/statics/class_statics_index'
import {BLUE} from '../config/styles'


//import CircleWebview from '../components/common/circle_webview'
//import TabBar from '../components/common/tab_bar'

const MainPage = TabNavigator({

    homework_index: {
        screen: HomeworkIndex,
        navigationOptions: {
            tabBarLabel: '作业',
            tabBarIcon: ({focused}) => {
                return(<Icon size={26} color={focused ? '#339aff' : 'grey'}  name={focused ? 'ios-home' : 'ios-home-outline'} />)
            }
        }
    },

    notification_index: {
        screen: NotificationIndex,
        navigationOptions: {
            tabBarLabel: '通知',
            tabBarIcon: ({focused}) => {
                return(<Icon size={26} color={focused ? '#339aff' : 'grey'}  name={focused ? 'ios-albums' : 'ios-albums-outline'} />)
            }
        }
    },

    self_learning_index: {
        screen: SelfLearningIndex,
        navigationOptions: {
            //title: '自学统计',
            tabBarLabel: '自学',
            tabBarIcon: ({focused}) => {
                return(<Icon size={26} color={focused ? '#339aff' : 'grey'}  name={focused ? 'ios-brush' : 'ios-brush-outline'} />)
            }
        }
    },

    personal_index: {
        screen: PersonalIndex,
        navigationOptions: {
            tabBarLabel: '我的',
            tabBarIcon: ({focused}) => {
                return(<Icon size={26} color={focused ? '#339aff' : 'grey'}  name={focused ? 'ios-contact' : 'ios-contact-outline'} />)
            }
        }
    }
    }, {
        initialRouteName: 'homework_index',
        tabBarPosition: 'bottom',
        swipeEnabled: false,
        animationEnabled: false,
        lazy: true,
        navigationOptions: {
            headerLeft: <View />,
            headerRight: <View />
        },
        //tabBarComponent: TabBar,
        tabBarOptions: {
            activeTintColor: '#5daeff',
            showIcon: true,
            labelStyle: {
                fontSize: 10,
                marginTop: Platform.select({ios: 10, android: 0}),
                color: 'gray'
                //paddingTop: 10
            },
            style: {
                height: 50,
                backgroundColor: 'white'
            },
            indicatorStyle: {
                height: 0
            }
        }
    }

)

const AppNavigation = StackNavigator({
    main_page: {
        screen: MainPage,
    },

    homeworks_correcting: {
        screen: HomeworkCorrecting
    },

    homeworks_show: {
        screen: HomeworkShow
    },

    new_homework: {
        screen: NewHomework,
        navigationOptions: {
            title: '新建作业'
        }
    },

    new_homework_without_text: {
        screen: newHomeworkWithoutText,
        navigationOptions: {
            title: '新建作业'
        }
    },

    new_homework_stage2: {
        screen: NewHomeworkStage2,
        navigationOptions: {
            title: '新建作业'
        }
    },

    new_homework_with_text: {
        screen: newHomeworkWithText,
        navigationOptions: {
            title: '新建作业'
        }
    },

    add_text_book: {
        screen: AddTextBook,
        navigationOptions: {
            title: '选择作业课文'
        }
    },

    teacher_correct: {
        screen: TeacherCorrect
    },

    homework_task_list: {
        screen: HomeworkTaskList,
        navigationOptions: {
            title: '作业单'
        }
    },

    correcting_with_task: {
        screen: CorrectingWithTask,
        navigationOptions: {
            title: '提交情况'
        }
    },

    student_homework_show: {
        screen: StudentHomeworkShow,
        navigationOptions: {
            title: '我的作业'
        }
    },

    notifications_show: {
        screen: NotificationShow
    },

    notifications_correcting: {
        screen: NotificationCorrecting
    },

    new_notification: {
        screen: NewNotification,
        navigationOptions: {
            title: '新建通知'
        }
    },

    new_notification_stage2: {
        screen: NewNotificationStage2,
        navigationOptions: {
            title: '新建通知'
        }
    },

    self_learning_show: {
        screen: SelfLearningShow
    },

    ranking_show: {
        screen: Ranking,
        navigationOptions: {
            title: '排行榜'
        }
    },

    chapters_list: {
        screen: ChaptersList,
        navigationOptions: {
            header: null
        }
    },

    feedback: {
        screen: Feedback,
        navigationOptions: {
            title: '意见反馈',
            //headerRight: <View />
        }
    },

    challenge: {
        screen: Challenge,
        navigationOptions: {
            title: '挑战模式'
        }
    },

    challenger_report: {
        screen: ChallengerReport,
        navigationOptions: {
            title: '成绩单'
        }
    },

    photo_show: {
        screen: PhotoBrowserScene
    },

    video_show: {
        screen: VideoBrowserScene,
        navigationOptions: {
            title: '视频播放'        
        }
    },

    grade_selector: {
        screen: GradeSelector,
        navigationOptions: {
            title: '选择年级'
        }
    },

    book_selector: {
        screen: BookSelector,
        navigationOptions: {
            title: '选择课本'
        }
    },

    unit_selector: {
        screen: UnitSelector,
        navigationOptions: {
            title: '选择单元'
        }
    },

    section_selector: {
        screen: SectionSelector,
        navigationOptions: {
            title: '选择课文'
        }
    },

    student_do_homework: {
        screen: StudentDoHomework
    },

    add_homework_describe: {
        screen: AddHomeworkDescribe,
        navigationOptions: {
            title: '作业描述'
        }
    },

    correcting_with_batch: {
        screen: CorrectingWithBatch
    },

    circle_slider_audio: {
        screen: CircleSliderAudio
    },

    symbol_show:{
        screen:Symbol,
        // navigationOptions: {
        //     title: '自学统计'
        // }
    },

    student_symbol_show:{
        screen:StudentSymbol,
        // navigationOptions: {
        //     title: '自学统计'
        // }
    },

    symbol_detail_show:{
        screen:SymbolDetail
    },

    swich_role:{
        screen:SwichRole,
        navigationOptions: {
            title: '身份切换'
        }
    },



}, {
    mode: 'card',
    navigationOptions: {
        gesturesEnabled: true,
        gestureResponseDistance: {
            vertical: 150,
            horizontal: 150
        },
        headerTintColor: 'white',
        shadowOpacity: 0,

        headerTitleStyle: {
            alignSelf: 'center',
            color: 'white',
            fontSize: 18,
        },

        headerStyle: {
            backgroundColor: BLUE,
            borderColor: BLUE,
            borderBottomWidth: 0,
            elevation: 0
        },

        headerBackTitle: null,

        headerBackTitleStyle: {
            color: 'white'

        },

        headerRight: <View />
    },

    transitionConfig: () => ({
        gestureResponseDistance:1,
        screenInterpolator: sceneProps => {
            const { layout, position, scene } = sceneProps;
            const { index } = scene;

            const translateX = position.interpolate({
                inputRange: [index - 1, index, index + 1],
                outputRange: [layout.initWidth, 0, 0]
            });

            const opacity = position.interpolate({
                inputRange: [index - 1, index - 0.99, index, index + 0.99, index + 1],
                outputRange: [0, 1, 1, 0.3, 0]
            });

            return { opacity, transform: [{ translateX }] }
        }
    }),

    

})


export default AppNavigation